<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="./dist/css/zx-editor.css">
		<style>
			body {
				margin: 0;
				padding: 0;
			}
			
			#editorContainer {
				padding: 15px;
				/*box-sizing: border-box;*/
			}
		</style>
	</head>

	<body>
		<!--头部-->
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: #000;"></a>
			<a style="color: #000;float: right;line-height: 44px;font-size: 16px;" id="save_note">完成</a>
		</header>
		<!--标题-->
		<input type="hidden" id="starid"/>
		<form class="mui-input-group">
			<div class="mui-input-row">
				<input type="text" id="note_title" class="mui-input-clear" placeholder="点击输入标题" style="border: none;">
			</div>
		</form>
		<!--文本内容-->
		<div class="mui-input-row">
			<div id="editorContainer"></div>
		</div>

		<script src="https://cdnjs.cloudflare.com/ajax/libs/js-polyfills/0.1.42/polyfill.min.js"></script>
		<script src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
		<script src="./dist/js/zx-editor.js"></script>
		<script src="./js/extend.js"></script>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript" src="js/jquery-3.4.1.js"></script>
		<script type="text/javascript">
			mui.init({
            	//返回父页面刷新
                    beforeback: function() {　　　　
                        var list = plus.webview.currentWebview().opener();　　　　
                        //refresh是父页面自定义事件
                        mui.fire(list, 'refresh');
                        //返回true,继续页面关闭逻辑
                        return true;
                    }
                });
			// 实例化 ZxEditor
			var zxEditor = new ZxEditor('#editorContainer', {
				editable: true,
				placeholder: '请输入正文',
			})
			$("dd[data-name=select-picture]").css("display","none");
			//完成按钮	
			var userid;
			var myUrl1;
			mui.plusReady(function(){
				userid = plus.storage.getItem("accessToken");
				myUrl1=plus.storage.getItem("myUrl1");
				//返回父页面
            	var self = plus.webview.currentWebview(); 
            	$('#starid').val(self.ids);
            	//给标题赋值
				$("#note_title").val(self.notesName);
				//给文本域赋值
				zxEditor.setHtml(self.content);
				//点击修改完成事件
				$('#save_note').click(function(){
        		$.ajax({
            		type:"get",
					url:""+myUrl1+"/note-star/notes/updateNotes",
					data:{
						ids: $('#starid').val(),
						notesName: $("#note_title").val(),
						content: zxEditor.getHtml(),
						token: userid
					},
					dataType:'json',
					success : function(d){
						mui.back();
					}
            	})
        	})
        	});

		</script>
	</body>

</html>